package com.jz.legalpersonclass.mapper;

import com.jz.legalpersonclass.model.LegalPersonSelectVo;
import com.jz.legalpersonclass.model.LegalPersonVo;
import com.jz.legalpersonclass.model.UserVo;
import com.jz.legalplantclass.entity.LegalVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by WISE on 2021/12/26.
 */
@Mapper
public interface LegalPersonMapper {


    List<LegalPersonVo> queryData(LegalPersonSelectVo legalPersonSelectVo);

    int queryCount(LegalPersonSelectVo legalPersonSelectVo);

    @Select("select * from subclass where legalPersonCode = #{legalPersonCode}")
    LegalPersonVo queryByCode(String legalPersonCode);

    @Select("select * from subclass where legalPersonName = #{legalPersonName}")
    LegalPersonVo queryByName(String legalPersonName);

    @Insert("insert into legalpersonclass(legalPersonName,legalPersonCode,enabled,userId,createTime,createName)" +
            "values(#{legalPersonName},#{legalPersonCode},#{enabled},#{userId},#{createTime},#{createName})")
    void add(LegalPersonVo classVo);

    @Select("select * from subclass where id = #{id}")
    LegalPersonVo queryById(Integer id);

    @Update("update legalpersonclass set legalPersonName = #{legalPersonName},enabled = #{enabled},updateTime = #{updateTime},updateName = #{updateName},version = #{version}+1 where id = #{id} and version = #{version}")
    int update(LegalPersonVo classVo);

    @Update("update legalpersonclass set enabled = #{enabled},updaetTime = #{updateTime},updateName = #{updateName} where id = #{id}")
    void updateStatus(LegalPersonVo classVo);

@Select("select * from user where userId = #{userId}")
    List<UserVo> queryDown(Integer userId);
}
